//
//  MovieTableViewCell.m
//  视频练习
//
//  Created by dllo on 15/9/29.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "MovieTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface MovieTableViewCell ()
@property(nonatomic,retain)UIImageView *profile_Image;
@property(nonatomic,retain)UILabel *namelabel;
@property(nonatomic,retain)UILabel *created_atlabel;
@property(nonatomic,retain)UILabel *textlabel;
@property(nonatomic,retain)UIImageView *bimageuriimage;
@property(nonatomic,retain)UILabel *lovelabel;
@property(nonatomic,retain)UILabel *hatelabel;
@property(nonatomic,retain)UILabel *repostlabel;
@property(nonatomic,retain)UILabel *commentlabel;
@property(nonatomic,copy)NSString *videouri;//视频
@end
@implementation MovieTableViewCell
- (void)dealloc
{
    [_profile_Image release];
    [_namelabel release];
    [_created_atlabel release];
    [_textlabel release];
    [_bimageuriimage release];
    [_lovelabel release];
    [_hatelabel release];
    [_repostlabel release];
    [_commentlabel release];
    [_videouri release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}
-(void)createView
{
    CGFloat width = [UIScreen mainScreen].bounds.size.width;
    self.profile_Image = [[UIImageView alloc]initWithFrame:CGRectMake(10*OffWidth, 10*OffHeight, 40*OffWidth, 40*OffHeight)];
    [self.contentView addSubview:self.profile_Image];
    self.profile_Image.layer.cornerRadius = 20.0*OffWidth;
    self.profile_Image.clipsToBounds = YES;
    [self.profile_Image release];
    
    self.namelabel = [[UILabel alloc]initWithFrame:CGRectMake(70*OffWidth, 5*OffWidth, width/3, 30*OffHeight)];
    [self.contentView addSubview:self.namelabel];
    [self.namelabel release];
    
    self.created_atlabel = [[UILabel alloc]initWithFrame:CGRectMake(70*OffWidth, 40*OffHeight, width-70*OffWidth, 30*OffHeight)];
    [self.contentView addSubview:self.created_atlabel];
    [self.created_atlabel release];
    
    
    self.textlabel = [[UILabel alloc]initWithFrame:CGRectMake(10*OffWidth, 70*OffHeight, width - 20*OffWidth, 30*OffHeight)];
    self.textlabel.numberOfLines = 0;
    [self.contentView addSubview:self.textlabel];
    [self.textlabel release];
    
    self.bimageuriimage = [[UIImageView alloc]initWithFrame:CGRectMake(10*OffWidth, 110*OffHeight, width - 20*OffWidth, 170*OffHeight)];
    [self.contentView addSubview:self.bimageuriimage];
    [self.bimageuriimage release];
    self.bimageuriimage.userInteractionEnabled = YES;
    
    UIImageView *play = [[UIImageView alloc]initWithFrame:CGRectMake(self.bimageuriimage.frame.size.width/2-20*OffWidth, self.bimageuriimage.frame.size.height/2 - 20*OffHeight, 50*OffWidth, 50*OffHeight)];
    play.image = [UIImage imageNamed:@"bofang.png"];
    [self.bimageuriimage addSubview:play];
    play.layer.cornerRadius = 25.0*OffWidth;
    play.clipsToBounds = YES;
    play.userInteractionEnabled = YES;
    [play release];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
    [play addGestureRecognizer:tap];
    [tap release];
}
-(void)tapAction:(UITapGestureRecognizer *)tap
{
//    NSLog(@"%@",self.model);
    [self.delegate clickImage:self.model];
}
-(void)sendModel:(MovieModel *)model
{    
    self.model = model;
    [self.profile_Image sd_setImageWithURL:[NSURL URLWithString:model.profile_image] placeholderImage:[UIImage imageNamed:@"29.png"]];
    self.namelabel.text = model.name;
    [self.profile_Image sd_setImageWithURL:[NSURL URLWithString:model.profile_image] placeholderImage:[UIImage imageNamed:@"29.png"]];
    self.created_atlabel.text = model.created_at;
    self.textlabel.text = model.text;
    [self.bimageuriimage sd_setImageWithURL:[NSURL URLWithString:model.bimageuri] placeholderImage:[UIImage imageNamed:@"29.png"]];
}
@end
